package com.atguigu.gmall.common.pool;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: lx
 * @Time: 14:29
 * @Description:
 * 多线程的线程池
 */
@Configuration
public class ThreadPools {

    //准备线程池
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        //1:办法
        //Executors.newCachedThreadPool()  强制禁止使用
        //2:创建线程池
        return new
                ThreadPoolExecutor(
                        5,//核心线程
                       10,//最大线程
                       10,//存活时间
                       TimeUnit.SECONDS,
                       new ArrayBlockingQueue(10)

        );


    }
}
